<template>
	<view>
		<view class="muu-top">
			<view class="title" @click="goToHome">{{config.title}}</view>
			<view class="items">
				<view class="item" @click="goToSearch">
					<text class="iconfont">&#xe601;</text>
				</view>
				<view class="item" @click="followWechat">
					<text class="iconfont">&#xe646;</text> 
				</view>
				<view class="item" @click="goToUcenter">
					<text class="iconfont">&#xe607;</text>
				</view>
			</view>
		</view>
		
		<!--关注公众号popup弹窗-->
		<uni-popup ref="openDetail" type="center">
			<view class="open-detail">
				<!-- 图片类型公告 -->
				<view class="open-detail-item type-image">
					<view class="qrcode-image">
						<image class="image" :src="config.config.follow.qrcode_url"></image>
						<view class="title">
							长按识别二维码
						</view>
					</view>
					
					<view class="close-icon" @click="close()">
						<text class="iconfont">&#xe622;</text>
					</view>
				</view>

			</view>
			
		</uni-popup>
	</view>
</template>

<script>
	import { mapState } from 'vuex'

	export default {
		props: {
			
		},
		data() {
			return {
				
			}
		},
		created() {
			
		},
		computed: {
			...mapState(['config'])
		},
		methods: {
			goToHome : function(){
				let url = '/muu_minishop/pages/index/index'
				console.log(url)
				uni.redirectTo({
					url: url
				});
			},
			goToSearch: function(){
				let url = '/muu_minishop/pages/search/index'
				uni.navigateTo({
					url: url
				});
			},
			/**
			 * 关注公众号
			 */
			followWechat: function(){
				this.$refs.openDetail.open()
			},
			close: function(){
				this.$refs.openDetail.close()
			},
			goToUcenter: function(){
				let url = '/muu_minishop/pages/my/index'
				uni.redirectTo({
					url: url
				});
			}
		}
	}
</script>

<style lang="scss">
	.muu-top {
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		display: flex;
		flex-wrap: wrap;
		padding: 10rpx;
		background-color: #fff;
		border-bottom: 2rpx solid #f8f8f8;
		z-index: 99;
		.title {
			flex: 1;
			padding-left: 10rpx;
			font-size: 28rpx;
			line-height: 48rpx;
		}
		.items {
			width: 250rpx;
			display: flex;
			flex-wrap: wrap;
			.item {
				flex: 1;
				text-align: center;
				line-height: 48rpx;
			}
		}
	}
	
	/*弹出公告样式*/
	.open-detail {
		.open-detail-item {
			
			padding: 20rpx;
			border-radius: 10rpx;
			.qrcode-image {
				background-color: #fff;
				padding: 20rpx;
				.image {
					width: 500rpx;
					height: 500rpx;
				}
				.title {
					text-align: center;
					font-size: 30rpx;
					color: #999;
					padding: 20rpx 0;
				}
			}
		}
		
		.close-icon {
			padding-top: 32rpx;
			text-align: center;
			color: #fff;
			.iconfont {
				font-size: 64rpx;
			}
		}
	}
</style>
